import { GoodDetailRankRequestParamsType } from "@/types/good";
import httpInstance from "@/utils/http";

// Detail页面请求商品详情参数API
export const getGoodDetailAPI = function (id: string) {
    // 用于取消请求的控制器
    const controller = new AbortController();
    // 进行请求
    const response = httpInstance({
        url: '/goods',
        params: { id },
        signal: controller.signal,
    });
    return { response, controller };
};

// Detail页面热榜信息请求API
export const getGoodDetailRankAPI = function ({ id, type, limit = 3 }: GoodDetailRankRequestParamsType) {
    // 用于取消请求的控制器
    const controller = new AbortController();
    // 进行请求
    const response = httpInstance({
        url: '/goods/hot',
        params: { id, type, limit },
        signal: controller.signal,
    });
    return { response, controller };
};